import React from 'react';
import ItemOrders from '../component/item-orders';
import {fromJS} from 'immutable';

export const columns = [
    {
        title: '商品',
        key: 'itemOrders',
        dataIndex: 'itemOrders',
        render: (v, record, index)=>{
            return {
                children: <ItemOrders itemOrders={fromJS(v)}/>,
                props: {
                    colSpan: 2
                }
            }
        }
    },
    {
        title: '成交单价/购买数量',
        key:"priceNumber",
        width: 150,
        className: 'ant-table-th-right',
        dataIndex: 'price-itemNumber',
        render: (value, record, index) => {
            return {
                props: {
                    colSpan: 0
                }
            }
        }
    },
    {
        title: '收款金额',
        width: 130,
        className: "ant-table-th-center va-t",
        dataIndex: 'actualeRfund',
        key:"actuale",
        render: (actualeRfund, record, index) => {
            let total = fromJS(record.itemOrders || []).reduce((total, item)=>total + item.get('itemNumber'), 0);
            return (
                <div className="real-pay">
                    <p className="total-price">&yen;{(record.totalTradeCash || 0).toFixed(2)}</p>
                    <p>（含运费：&yen;{(record.logisticsFee || 0).toFixed(2)}）</p>
                    <p>共{total}件</p>
                </div>
            )
        }
    },
];